<?php
/*
	Helper for student photo
	retrieves students photo from photo directory
	if none returns default photo.

*/

if(!function_exists('student_photo'))
{
	function student_photo($photo_name = NULL,$gender)
	{
		$CI=& get_instance();
		$CI->load->helper(array('file'));
		
		
		$photo_path = 'assets/uploads/photos/'.$photo_name.'.jpg';
		$female_def_path = 'assets/img/user-female-icon.png';
		$male_def_path = 'assets/img/user-male-icon.png';
		
		
		if(file_exists($photo_path))
		{
			return $CI->config->base_url($photo_path);
		}else{
			if(file_exists($female_def_path) AND file_exists($male_def_path))
			{
				if($gender == 'female')
				{
					return image_url('user-female-icon.png');
				}else{
					return image_url('user-male-icon.png');
				}
			}else{
				return 'http://placehold.it/200x200';
			}
		}
	}
}

if(!function_exists('employee_photo'))
{
	function employee_photo($photo_name = NULL,$gender)
	{
		$CI=& get_instance();
		$CI->load->helper(array('file'));
		
		$photo_path = 'assets/uploads/employees/'.$photo_name.'.jpg';
		$female_def_path = 'assets/img/user-female-icon.png';
		$male_def_path = 'assets/img/user-male-icon.png';
		
		if(file_exists($photo_path))
		{
			return $CI->config->base_url($photo_path);
		}else{
			if(file_exists($female_def_path) AND file_exists($male_def_path))
			{
				if($gender == 'f')
				{
					return image_url('user-female-icon.png');
				}else{
					
					return image_url('user-male-icon.png');
				}
			}else{
				return 'http://placehold.it/200x200';
			}
		}
	}
}

if(!function_exists('employee_thumbs'))
{
	function employee_thumbs($photo_name = NULL,$gender)
	{
		$CI=& get_instance();
		$CI->load->helper(array('file'));
		
		$photo_path = 'assets/uploads/thumbs/'.$photo_name.'_thumb.jpg';
		$female_def_path = 'assets/img/female.png';
		$male_def_path = 'assets/img/male.png';
		
		
		if(file_exists($photo_path))
		{
			return $CI->config->base_url($photo_path);
		}else{
			if(file_exists($female_def_path) AND file_exists($male_def_path))
			{
				if(strtolower($gender) == 'm')
				{
					return image_url('male.png');
				}elseif(strtolower($gender) == 'f'){
					return image_url('female.png');
				}else{
					return image_url('unknown.png');
				}
			}else{
				return image_url('unknown.png');
			}
		}
	}
}